package javase.javase01.exercise07;

import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Scanner;

/**
 * @author: Gan
 * @date 2021/4/20 0020 17:27
 * @description:
 **/
public class MyThread {
    public static void main(String[] args) throws IOException {
        SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");


        boolean flag ;
        FileWriter fw = new FileWriter("log.txt");
        NewThread nt = new NewThread();
        String s = new Scanner(System.in).next();
        if (s.equals("true")){
            nt.start();
        }else {
            fw.write(date+":某个线程终止了！");
            fw.close();
            return;
        }


    }
}
class NewThread extends Thread{
    public NewThread(String name) {
        super(name);
    }

    public NewThread() {
    }

    @Override
    public void run() {

        for (int i = 0; i < 4; i++) {
            System.out.println(this.getName()+"-------->"+i);
        }
    }
}